package com.gallop.mq.core.template;

import com.gallop.mq.MQProperties;
import com.gallop.mq.MQTemplate;
import com.gallop.mq.core.MQExecutorProvider;
import com.gallop.mq.core.MQMessageCodec;
import com.gallop.mq.core.MQMessageDispatcher;
import com.gallop.mq.core.exception.MQException;
import com.gallop.mq.core.template.handler.registry.MessageDeliveryHandlerRegistry;
import lombok.extern.slf4j.Slf4j;

import java.time.Duration;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

@Slf4j
public class NopTemplate implements MQTemplate {

    @Override
    public void init(MQProperties properties, MQMessageDispatcher dispatcher, MQMessageCodec codec, MQExecutorProvider executorProvider, MessageDeliveryHandlerRegistry handlerRegistry) throws MQException {
        if (log.isDebugEnabled()) {
            log.debug("NopTemplate#init invoked.");
        }
    }

    @Override
    public MQMessageCodec getCodec() {
        if (log.isDebugEnabled()) {
            log.debug("NopTemplate#getCodec invoked.");
        }
        return null;
    }

    @Override
    public void setCodec(MQMessageCodec codec) {
        if (log.isDebugEnabled()) {
            log.debug("NopTemplate#setCodec invoked.");
        }
    }

    @Override
    public MQMessageDispatcher getDispatcher() {
        if (log.isDebugEnabled()) {
            log.debug("NopTemplate#getDispatcher invoked.");
        }
        return null;
    }

    @Override
    public void setDispatcher(MQMessageDispatcher dispatcher) {
        if (log.isDebugEnabled()) {
            log.debug("NopTemplate#setDispatcher invoked.");
        }
    }

    @Override
    public void send(Object message, String topic) {
        if (log.isDebugEnabled()) {
            log.debug("NopTemplate#send invoked.");
        }
    }

    @Override
    public <P> void request(Object message, String topic, Duration requestTimeout, Consumer<P> onResponse) {
        if (log.isDebugEnabled()) {
            log.debug("NopTemplate#request invoked.");
        }
    }

    @Override
    public <P> void request(Object message, String topic, Duration requestTimeout, Consumer<P> onResponse, BiConsumer<Object, Exception> onError) {
        if (log.isDebugEnabled()) {
            log.debug("NopTemplate#request invoked.");
        }
    }

    @Override
    public <P> P request(Object message, String topic, Duration receiveTimeout) throws InterruptedException {
        if (log.isDebugEnabled()) {
            log.debug("NopTemplate#request invoked.");
        }
        return null;
    }
}
